<%--
  Created by IntelliJ IDEA.
  User: zzf
  Date: 2021/1/7
  Time: 16:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="/public/header/permissionCommon.jspf" %>
<html>
<head>
    <title>老人信息管理</title>
    <style type="text/css">
        /*选项卡样式*/
        .first-tab i.layui-tab-close{
            display:none!important;
        }
        .laytable-cell-radio {
            padding-top:15px;
        }
        .layui-table-tips-main{display:none}
        .layui-table-tips-c{display:none}
        .layui-table-grid-down {display: none;}

        textarea::-webkit-input-placeholder { /* WebKit browsers */color:black;}
        textarea:-moz-placeholder { /* Mozilla Firefox 4 to 18 */color:black;}
        textarea::-moz-placeholder { /* Mozilla Firefox 19+ */color:black;}
        textarea::-ms-input-placeholder { /* Internet Explorer 10+ */color:black;}
    </style>
</head>

<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <!-- 头部和左侧导航-->
    <div id="header"></div>
    <!--右侧主体区域-->
    <div class="layui-body" >
        <div class="layui-tab layui-tab-brief" lay-filter="demo" lay-allowClose="true">
            <ul class="layui-tab-title">
                <li class="layui-this first-tab" lay-id="arrangeInfo">派工单信息</li>
                <li class="first-tab" lay-id="arrangeDate">派工日程安排</li>
            </ul>
            <div class="layui-tab-content">
                <%---------- 派工单查询页面 ---------%>
                <div id="ArrangeInfoDiv" class="layui-tab-item layui-show">
                    <%-----------搜索功能-----------%>
                    <div class="SearchLoadArrangeInfo" style="font-size: small">
                        服务机构名称：
                        <div class="layui-inline">
                            <input class="layui-input" name="serv_org" id="serv_org" autocomplete="off" style="height: 38px;width:200px;margin-right: 20px">
                        </div>
                        服务机构结算代码：
                        <div class="layui-inline">
                            <input class="layui-input" name="settle_code" id="settle_code" autocomplete="off" style="height: 38px;width:200px;margin-right: 20px">
                        </div>
                        订&nbsp&nbsp&nbsp单&nbsp&nbsp&nbsp状&nbsp&nbsp&nbsp态&nbsp&nbsp&nbsp：&nbsp
                        <div class="layui-input-inline layui-form" style="width: 200px;margin-right: 20px;">
                            <select name="serv_status" id="serv_status" lay-filter="serv_status" class="select" >
                                <option value="" style="height: 30px">请选择状态类型</option>
                                <option value="有效">有效</option>
                                <option value="过期">无效</option>
                            </select>
                        </div>
                        <br><br>
                        老&nbsp&nbsp人&nbsp&nbsp姓&nbsp&nbsp名&nbsp：
                        <div class="layui-inline">
                            <input class="layui-input" name="elder_name" id="elder_name" autocomplete="off" style="height: 38px;width:200px;margin-right: 20px">
                        </div>
                        老&nbsp&nbsp人&nbsp&nbsp医&nbsp&nbsp保&nbsp&nbspID&nbsp&nbsp：&nbsp
                        <div class="layui-inline">
                            <input class="layui-input" name="elder_yb_id" id="elder_yb_id" autocomplete="off" style="height: 38px;width:200px;margin-right: 20px">
                        </div>
                        老 人 身 份 证 号 ：
                        <div class="layui-inline">
                            <input class="layui-input" name="elder_id" id="elder_id" autocomplete="off" style="height: 38px;width:200px;margin-right: 20px">
                        </div>
                        <br><br>
                        护&nbsp&nbsp工&nbsp&nbsp姓&nbsp&nbsp名&nbsp：
                        <div class="layui-inline">
                            <input class="layui-input" name="nursing_name" id="nursing_name" autocomplete="off" style="height: 38px;width:200px;margin-right: 20px">
                        </div>
                        护&nbsp&nbsp工&nbsp&nbsp医&nbsp&nbsp保&nbsp&nbspID&nbsp&nbsp：&nbsp
                        <div class="layui-inline">
                            <input class="layui-input" name="nursing_yb_id" id="nursing_yb_id" autocomplete="off" style="height: 38px;width:200px;margin-right: 20px">
                        </div>
                        护 工 身 份 证 号 ：
                        <div class="layui-inline">
                            <input class="layui-input" name="nursing_id" id="nursing_id" autocomplete="off" style="height: 38px;width:200px;margin-right: 20px">
                        </div>
                        <br><br>
                        护理开始日期：
                        <div class="layui-inline">
                            <input class="layui-input" type="text" name="serv_start_date" id="serv_start_date" autocomplete="off" style="height: 38px;width:200px;margin-right: 20px">
                        </div>
                        护 理 结 束 日 期 ：&nbsp
                        <div class="layui-inline">
                            <input class="layui-input" type="text" name="serv_due_date" id="serv_due_date" autocomplete="off" style="height: 38px;width:200px;margin-right: 20px">
                        </div>
                        每次护理开始时间：
                        <div class="layui-inline">
                            <input class="layui-input" type="text" name="serv_start_time" id="serv_start_time" autocomplete="off" style="height: 38px;width:200px;margin-right: 20px">
                        </div>
                        <br><br>
                        <%------------- 按键（搜索/新增） -------------%>
                        <div class="layui-inline" style="float: right;margin-top: -200px;margin-right: 20px">
                            <button class="layui-btn" data-type="reload1" style="border-radius: 5px;width: 120px">
                                <i class="layui-icon layui-icon-search"></i>
                                <div class="layui-inline">&nbsp搜&nbsp&nbsp&nbsp&nbsp&nbsp索</div>
                            </button>
                        </div>
                        <%-------------文件导入-------------%>
                        <div class="layui-inline" style="float: right;margin-top: -150px;margin-right: 20px">
                            <button class="layui-btn" id="importExcel" name="importExcel" style="border-radius: 5px;width: 120px;background-color:#FF5722">
                                <i class="layui-icon layui-icon-export"></i>
                                <div class="layui-inline" style="font-size: small;text-align:center;margin-top: -3px">导入文件</div>
                            </button>
                        </div>
                        <%-------------文件导出-------------%>
                        <div class="layui-inline" style="float: right;margin-top: -100px;margin-right: 20px">
                            <button class="layui-btn" id="exportExcel" name="exportExcel" style="border-radius: 5px;width: 120px;background-color: #1E9FFF">
                                <i class="layui-icon layui-icon-export"></i>
                                <div class="layui-inline" style="font-size: small;text-align:center;margin-top: -3px">导出文件</div>
                            </button>
                        </div>
                        <%-------------订单新增-------------%>
                        <div class="layui-inline" style="float: right;margin-top: -50px;margin-right: 20px">
                            <button class="layui-btn layui-btn-warm" data-type="tabAdd" id="newOrder" name="newOrder" style="width: 120px;border-radius: 5px">
                                <i class="layui-icon layui-icon-add-1"></i>
                                <div class="layui-inline">新增订单</div>
                            </button>
                        </div>
                    </div>
                    <%------------- 派工信息表格渲染 -------------%>
                    <table class="layui-hide" id="arrangeInfoList" lay-filter="arrangeInfo"></table>
                </div>
                <%------------------ 用于页面间传值（隐藏） ---------------%>
                <input class="layui-input" value="" id="transferElderYbid" style="display: none"/>
                <input class="layui-input" value="" id="transferArrangeID" style="display: none"/>
                <%---------- 派工单日程安排页面 ---------%>
                <div id="ArrangeScheduleDiv" class="layui-tab-item">
                    <iframe src="/arrangeInfo/toDateArrangeInfo"  name="dateArrange" style="height:1400px;width: 100%;border:none"></iframe>
                </div>
            </div>
        </div>
    </div>
    <!--底部-->
    <div id="footer"></div>
    <%--<script src="${webPath}/js/permission/auth/permList.js"></script>--%>
    <script>
        $("#header").load("${webPath}/publicPages/permission/fragments/header.jsp");
        $("#footer").load("${webPath}/publicPages/permission/fragments/footer.jsp");
    </script>

    <!------------ 派工单JS文件 ---------->
    <script type="text/javascript" src="${webPath}/js/arrangeInfo/ArrangeInfo.js"></script>
    <script type="text/javascript" src="${webPath}/lib/jquery-3.3.1.min.js"></script>
    <%-------------编辑删除框--------------%>
    <%--查看页面的编辑框--%>
    <script type="text/html" id="Check_Edit_Del">
        <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="arrange">排程</a>
        <a class="layui-btn layui-btn-xs" lay-event="detail">查看</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
    <%------------- 查看功能 --------------%>
    <script type="text/javascript" src="${webPath}/js/utils.js"></script>
    <div class="arrangeDetail" id="arrangeDetail" style="display: none">
        <form class="layui-form layui-form-pane" style="margin-top: 20px;margin-left: 10px;margin-right: 10px;">
            <div class="layui-form-item">
                <label class="layui-form-label">服务机构</label>
                <div class="layui-input-block">
                    <input type="text" name="serv_org" value={serv_org} class="layui-input" readonly="readonly">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">结算代码</label>
                <div class="layui-input-block">
                    <input type="text" name="settle_code" value={settle_code} class="layui-input" readonly="readonly">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">护工姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="nursing_name" value={nursing_name} class="layui-input" readonly="readonly">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">护工医保ID</label>
                    <div class="layui-input-block">
                        <input type="text" name="nursing_yb_id" value={nursing_yb_id} class="layui-input" readonly="readonly">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="height: 55px;white-space:pre-line!important;">护工身份证号</label>
                <div class="layui-input-block">
                    <input style="height: 55px;" type="text" name="nursing_id" value={nursing_id} class="layui-input" readonly="readonly">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">老人姓名</label>
                    <div class="layui-input-block">
                        <input  type="text" name="elder_name" value={elder_name} class="layui-input" readonly="readonly">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">老人医保ID</label>
                    <div class="layui-input-block">
                        <input type="text" name="elder_yb_id" value={elder_yb_id} class="layui-input" readonly="readonly">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="height: 55px;white-space:pre-line!important;">老人身份证号</label>
                <div class="layui-input-block">
                    <input style="height: 55px;" class="layui-input" type="text" name="elder_id" value={elder_id} readonly="readonly" >
                </div>
            </div>
            <div class="layui-form-item" >
                <div class="layui-col-xs6">
                    <label class="layui-form-label">周一</label>
                    <div class="layui-input-block">
                        <input type="text" name="serv_monday" value={serv_monday} class="layui-input" readonly="readonly">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">周二</label>
                    <div class="layui-input-block">
                        <input type="text" name="serv_tuesday" value={serv_tuesday} readonly="readonly" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">周三</label>
                    <div class="layui-input-block">
                        <input type="text" name="serv_wednesday" readonly="readonly" value={serv_wednesday} class="layui-input">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">周四</label>
                    <div class="layui-input-block">
                        <input type="text" name="serv_thursday" value={serv_thursday} readonly="readonly" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">周五</label>
                    <div class="layui-input-block">
                        <input type="text" name="serv_friday" readonly="readonly" value={serv_friday} class="layui-input">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">周六</label>
                    <div class="layui-input-block">
                        <input type="text" name="serv_saturday" readonly="readonly" value={serv_saturday} class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">周日</label>
                    <div class="layui-input-block">
                        <input type="text" name="serv_sunday" readonly="readonly" value={serv_sunday} class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label" style="height: 55px;white-space:pre-line!important;">服务开始时间</label>
                    <div class="layui-input-block">
                        <input style="height: 55px;" type="text" name="serv_start_date" value={serv_start_date} readonly="readonly" class="layui-input">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label" style="height: 55px;white-space:pre-line!important;">服务到期时间</label>
                    <div class="layui-input-block">
                        <input style="height: 55px;" type="text" name="serv_due_date" readonly="readonly" value={serv_due_date} class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="height: 55px;white-space:pre-line!important;">服务项具体内容</label>
                <div class="layui-input-block">
                    <input class="layui-input" style="height: 55px;" type="text" value={serv_content} name="serv_content" readonly="readonly"/>
                </div>
            </div>
        </form>
    </div>


    <%------------------- 信息页面 EXCEL 文件上传------------------%>
    <script type="text/javascript">
        layui.use('upload', function(){
            var $ = layui.jquery
                ,upload = layui.upload;
            upload.render({
                elem: '#importExcel'
                ,url: '/arrangeInfo/InputExcel' //改成您自己的上传接口
                ,accept: 'file' //普通文件
                ,exts: 'xls|xlsx' //只允许上传压缩文件
                ,done: function(res){
                    console.log("触发导入事件");
                    console.log(res);
                    if(res.msg=="ok"){
                        layer.msg("文件导入成功",{icon: 1, time: 1500},function(){location.reload();});
                        // alert("文件导入成功");
                    }else{
                        layer.msg("文件导入失败",{icon: 2, time: 1500},function(){location.reload();});
                        // alert("文件导入失败失败");
                    }
                }
                ,error:function(){
                    layer.msg("文件导入失败",{icon: 2, time: 1500},function(){location.reload();});
                }
            });
        })
    </script>
    <%------------------- 信息页面 EXCEL 文件导出------------------%>
    <script type="text/javascript">
        layui.config({//配置并导入excel插件
            base: '${base}/js/layui_exts/'
        }).use([ 'excel', 'layer'], function() {
            var $ = layui.$;
            var layer = layui.layer;
            var excel = layui.excel;
            $('#exportExcel').on('click', function(){
                console.log("触发导出按钮");
                var send_serv_org = $('#serv_org');var send_settle_code = $('#settle_code');var send_serv_status=$('#serv_status');
                var send_elder_name = $('#elder_name');var send_elder_yb_id = $('#elder_yb_id');var send_elder_id=$('#elder_id');
                var send_nursing_name = $('#nursing_name');var send_nursing_yb_id = $('#nursing_yb_id');var send_nursing_id=$('#nursing_id');
                var send_serv_start_date = $('#serv_start_date');var send_serv_due_date = $('#serv_due_date');var send_serv_start_time=$('#serv_start_time');
                // console.log("导出：搜索的机构是"+send_name.val());
                // console.log("导出：搜索的区内编码是"+send_code.val());
                // console.log("导出：搜索的状态是"+send_status.val());
                layer.confirm('是否确认导出', function(index) {
                    $.ajax({
                        url: '/arrangeInfo/ExportArrangeInfo'
                        ,method:'post'
                        ,data: {
                            servOrg: send_serv_org.val(), settleCode: send_settle_code.val(), servStatus:send_serv_status.val(),
                            elderName: send_elder_name.val(), elderYbid: send_elder_yb_id.val(), elderId:send_elder_id.val(),
                            nursingName: send_nursing_name.val(), nursingYbid: send_nursing_yb_id.val(), nursingId:send_nursing_id.val(),
                            startDate: send_serv_start_date.val(), dueDate: send_serv_due_date.val(), startTime:send_serv_start_time.val()
                        }
                        , dataType: 'json'
                        , success(res) {
                            var data = res;
                            console.log(res);
                            layer.close(index);
                            data = excel.filterExportData(data, [
                                'serv_org', 'settle_code', 'nursing_yb_id', 'nursing_name', 'nursing_id', 'elder_yb_id'
                                , 'elder_name', 'elder_id', 'serv_monday', 'serv_tuesday', 'serv_wednesday', 'serv_thursday'
                                , 'serv_friday', 'serv_saturday', 'serv_sunday', 'serv_start_date', 'serv_due_date'
                                , 'arrange_time'
                            ]);
                            data.unshift({
                                serv_org: "机构名称", settle_code: "结算代码",
                                nursing_yb_id: '护工医保卡号', nursing_name: "护工姓名", nursing_id: "护工身份证号",
                                elder_yb_id: '老人医保卡号', elder_name: "老人姓名",elder_id:"老人身份证号",
                                serv_monday: "周一", serv_tuesday: '周二', serv_wednesday: "周三", serv_thursday: "周四",
                                serv_friday: "周五", serv_saturday: "周六", serv_sunday: "周日",
                                serv_start_date: '护理开始日期', serv_due_date: "护理结束日期",
                                arrange_time: "订单制定日期"
                            });
                            // var timestart = Date.now();
                            excel.exportExcel(data, '派工信息导出--' + new Date().toLocaleString() + '.xlsx', 'xlsx');
                            //	var timeend = Date.now();
                            //	var spent = (timeend - timestart) / 1000;
                            //	console.log('单纯导出耗时 '+spent+' s');
                        }
                        , error() {
                            layer.alert('获取数据失败，请检查是否部署在本地服务器环境下');
                        }
                    });
                });
            });
        });
    </script>
</div>
</body>
</html>
